﻿@using PageAdmin.Common;
@using PageAdmin.Utils;
@{
    var installEnabled = ViewBag.InstallEnabled;
    Layout = null;
    System.Diagnostics.Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();
    string lastTime = null, lastIp = null, logins = null;
    dynamic userData = ViewBag.CurrentUserData;
    if (userData != null)
    {
        lastTime = userData.LastDate.ToString("yyyy-MM-dd HH:mm:ss");
        lastIp = userData.LastIp.ToString();
        logins = userData.Logins.ToString();
    }
    CurrentUser user = (CurrentUser)ViewBag.CurrentUser;
    int bindEmailState = (int)ViewBag.EmailBindState;
    int bindMobileState = (int)ViewBag.MobileBindState;
    string securityLevel = "低";
    if (bindEmailState == 1 && bindMobileState == 1)
    {
        securityLevel = "高";
    }
    else if (bindEmailState == 1 || bindMobileState == 1)
    {
        securityLevel = "中";
    }
}
<!DOCTYPE HTML>
<HTML>
<head>
    <title>极简木材网站管理系统</title>
    <meta name="Author" content="PageAdmin CMS" />
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="stylesheet" href="/Incs/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/Incs/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="~/Areas/Admin/Css/Home.css" type="text/css">
    <script src="/Js/jquery.min.js" type="text/javascript"></script>
    <script src="/Js/basic.js" type="text/javascript"></script>
    <script src="/Js/UI/ui.js" type="text/javascript"></script>
    <!--[if lte IE 9]>
    <script src="/Incs/bootstrap/js/respond.min.js"></script>
    <script src="/Incs/bootstrap/js/html5.js"></script>
    <![endif]-->
    <script src="/Incs/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
</head>
<body>
    <div class="current-location">
        <ul>
            <li class="left"><i class="glyphicon glyphicon-home"></i><a href="javascript:void(0)" onclick="location.href=location.href">后台首页</a></li>
        </ul>
    </div>
    <div class="main clearfix">
        <div class="alert alert-warning alert-dismissible hidden" role="alert" id="boxAuthorize">
            <a data-dismiss="alert" class="close">×</a>
            授权提示：当前的站点域名还未经过极简木材官方商业授权许可！
        </div>
        @if (installEnabled == "true")
        {
            <div class="alert alert-warning alert-dismissible" role="alert" id="boxInstallEnabled">
                <a data-dismiss="alert" class="close">×</a>
                安全提示：请到系统设置>>安全设置中把安装状态设为禁止安装，<a href = "@Url.ActionUrl("index","SysSet")">点击设置！</a>
            </div>
        }
        <div class="account-info clearfix">
            <div class="account-left"><i class="fa fa-user-circle"></i></div>
            <div class="account-body">
                <h4>
                    欢迎您，@(user.UserName)
                    <small>&nbsp;&nbsp;&nbsp;&nbsp;角色：@ViewBag.RoleName </small>
                    <small>&nbsp;&nbsp;&nbsp;&nbsp;用户组：@ViewBag.MemberGroupName </small>
                    @if (!string.IsNullOrEmpty(ViewBag.DepartmentName))
                    {<small>&nbsp; &nbsp; &nbsp; 部门：@ViewBag.DepartmentName </small>}
                </h4>
                <p>
                    这是您第 @logins 次登录，上次登录日期：@lastTime，登录Ip:@lastIp
                </p>
                <p class="security">
                    <i class="fa fa-shield fa-lg"></i><span>安全等级：@securityLevel</span>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <i class="fa fa-envelope fa-lg @(bindEmailState==1?"":"no-bind")"></i><span>@(bindEmailState == 1 ? "已绑定" : "未绑定")</span>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <i class="fa fa-mobile-phone fa-lg fa-2 @(bindMobileState==1?"":"no-bind")"></i><span>@(bindMobileState == 1 ? "已绑定" : "未绑定")</span>
                </p>

            </div>
        </div>

        <div class="panel notice-box">
            <div class="panel-heading clearfix">
                <span class="left">站内公告</span>
            </div>
            <div class="panel-body">
                <ul id="noticeList" class="title-list">
                    <li class="item clearfix">
                        <a class="title" href="{_url}" target="_blank"><i class="fa fa-angle-right" aria-hidden="true"></i> {title} <span class="date">/ {thedate}</span></a>
                    </li>
                </ul>
            </div>
            <script type="text/javascript">
                    $("#noticeList").ListBind({ url:'@Url.ActionUrl("GetWebNotice")?number=6', showFooter: false });
            </script>
        </div>

        <div class="panel sys-info">
            <div class="panel-heading">系统相关信息</div>
            <div class="panel-body">
                <table class="table">
                    <tr>
                        <td width="150px">版本号：</td>
                        <td>
                            @(ViewBag.CurrentVersion)
                        </td>
                    </tr>
                    <tr>
                        <td>版本检测：</td>
                        <td>
                            <span id="checkUpgrade"><i class="fa fa-spinner fa-spin"></i>正在检查更新</span>
                        </td>
                    </tr>
                    <tr id="trAuthorize" class="hidden">
                        <td>授权许可：</td>
                        <td>
                            <span id="spAuthorize"></span>
                        </td>
                    </tr>
                    <tr id="spServiceExpire" class="hidden">
                        <td>售后服务：</td>
                        <td>
                            <span id="spServiceExpire">已到期</span>
                        </td>
                    </tr>
                    <tr>
                        <td>运行环境：</td>
                        <td>@Request.ServerVariables["SERVER_SOFTWARE"]   .Net @System.Environment.Version.ToString()</td>
                    </tr>
                    <tr>
                        <td>客户端/服务器Ip：</td>
                        <td>@SysHelper.ClientIP()/@Request.ServerVariables["LOCAL_ADDR"]</td >
                    </tr>
                    <tr>
                        <td>当前进程占用内存：</td>
                        <td>@((((double)currentProcess.WorkingSet64) / 1024 / 1024).ToString("f2"))MB</td>
                    </tr>

                    <tr>
                        <td>当前进程总线程数：</td>
                        <td>@currentProcess.Threads.Count</td>
                    </tr>

                    <tr>
                        <td>当前进程启动时间：</td>
                        <td>@currentProcess.StartTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
                    </tr>
                    <tr>
                        <td>服务器目录：</td>
                        <td>@Server.MapPath("/")</td>
                    </tr>
                    <tr>
                        <td>当前域名：</td>
                        <td>@Request.ServerVariables["SERVER_NAME"]:@Request.ServerVariables["SERVER_PORT"]</td>
                    </tr>
                    <tr>
                        <td>官方网站：</td>
                        <td><a href=http://www.pageadmin.net target="pageadmin">http://www.pageadmin.net</a></td>
                    </tr>
                </table>
            </div>
        </div>


    </div>
    <script type="text/javascript">
                    var $main = $(".main");
                    var $checkUpgrade = $("#checkUpgrade");
                    var $trAuthorize = $("#trAuthorize");
                    var $spAuthorize = $("#spAuthorize");
                    var $boxAuthorize = $("#boxAuthorize");
                    var $spServiceExpire = $("#spServiceExpire");
                    //检测系统信息
                    Ajax({ url: '@Url.ActionUrl("CmsInfo")' },
                        function (result) {
                            var result = JsonParse(result);
                            if (result == undefined) {
                                $checkUpgrade.html("当前已是最新版本");
                                return;
                            }
                            var latestVersion = result.LatestVersion;
                            var authorize = result.Authorize;
                            var serviceExpire = result.ServiceExpire;
                            switch (latestVersion)
                            {

                                case 0:
                                    $checkUpgrade.html("<a href=\"@Url.ActionUrl("index", "OnlineUpgrade")\"><i class=\"fa fa-lightbulb-o text-primary\"></i><span class=\"text-primary\">有新的版本，点击立即更新！</span></a>")
                                    break;
             case 1:
                $checkUpgrade.html("当前已是最新版本")
                break;
              default:
                 $checkUpgrade.html("error!")
                break;
            }
            switch (authorize)
            {
                case 0:
                    $boxAuthorize.removeClass("hidden");
                    $spAuthorize.text("未授权");
                break;
                case 1:
                    $trAuthorize.removeClass("hidden");
                    $spAuthorize.html("<i class=\"fa fa-id-card\" aria-hidden=\"true\"></i>已授权");
                    if (serviceExpire==1)
                    {
                        $spServiceExpire.removeClass("hidden");
                    }


                break;
              default:
                    $spAuthorize.html("error!")
                break;
            }
            },
            function (httpRequest, status) {
                console.log("http" + httpRequest.status + "错误:" + httpRequest.responseText + "/" + status);
                $checkUpgrade.html("<span class=\"text-warning\">检测失败，请确保网络连接正常!</a>")
            });
    </script>
</body>
</HTML>
